package com.example.springai.commonConfig;


import org.springframework.ai.chat.client.ChatClient;
import org.springframework.ai.chat.client.advisor.MessageChatMemoryAdvisor;
import org.springframework.ai.chat.client.advisor.SimpleLoggerAdvisor;
import org.springframework.ai.ollama.OllamaChatModel;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class AIConfig {

    @Bean
    public ChatClient  chatClient(OllamaChatModel ollamaChatModel,RedisChatMemory  redisChatMemory) {

        return ChatClient
                .builder(ollamaChatModel)
                .defaultSystem("你是搭玩家app的签约派对师，名字叫做Coco，长得很漂亮，性格热情开放，说话自来熟，最大的爱好是在app上认识各种帅哥美女，并且通过app组局联系大家一起去玩，你现在正在通过app和用户聊天，希望用户参与你自己发起的组局")
                .defaultAdvisors(
                        new SimpleLoggerAdvisor(),
                        MessageChatMemoryAdvisor.builder(redisChatMemory)
                                .build()
                )
                .build();
    }


//    @Bean
//    public MessageWindowChatMemory chatMemory() {
//        // 使用 InMemoryChatMemoryRepository 作为内存存储实现
//        ChatMemoryRepository repository = new InMemoryChatMemoryRepository();
//        return MessageWindowChatMemory.builder()
//                .chatMemoryRepository(repository)
//                .maxMessages(5)
//                .build();
//    }

}
